package code20211108;

import java.util.HashMap;
import java.util.Map;

public class C299 {

	public static void main(String[] args) {
		System.out.println(getHint("112244","142233"));

	}
	public static String getHint(String secret, String guess) {
		int n = Math.min(secret.length(), guess.length());
		int bulls = 0, cows = 0;
		Map<Character, Integer> maps = new HashMap<>();
		for(int i=0;i<n;i++) {
			maps.put(secret.charAt(i), maps.getOrDefault(secret.charAt(i), 0)+1);
		}
		for(int i=0;i<n;i++) {
			if(secret.charAt(i)==guess.charAt(i)) {
				bulls++;
				maps.put(secret.charAt(i), maps.get(secret.charAt(i))-1);
			}
		}
		for(int i=0;i<n;i++) {
			if(secret.charAt(i)!=guess.charAt(i)) {
				if(maps.containsKey(guess.charAt(i))&&maps.get(guess.charAt(i))>0) {
					cows++;
					maps.put(guess.charAt(i), maps.get(guess.charAt(i))-1);
				}
			}
		}
		return bulls+"A"+cows+"B";
    }

}
